<template>
	<view class="page_bg">
		<!-- #ifdef APP-PLUS -->
		<view class="status_bar">
			<view class="top_view"></view>
		</view>
		<!-- #endif -->
		<view class="top_nav">
			<image src="/static/local/3546451940011a031009b939a8b26314.png" class="image_1" @click="pageBack" />
			<view class="cate">{{title}}</view>
		</view>
		<scroll-view scroll-y class="rich">
			<mp-html :content="richText"></mp-html>
		</scroll-view>
	</view>
</template>

<script>
	var that; // 当前页面对象
	var vk; // vk依赖
	export default {
		data() {
			// 页面数据变量
			return {
				title: '',
				richText: ''
			}
		},
		// 监听 - 页面每次【加载时】执行(如：前进)
		onLoad(options = {}) {
			that = this;
			vk = that.vk;
			that.init(options)
		},
		// 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快，会在页面进入动画完成前触发
		onReady() {},
		// 监听 - 页面每次【显示时】执行(如：前进和返回) (页面每次出现在屏幕上都触发，包括从下级页面点返回露出当前页面)
		onShow() {},
		// 监听 - 页面每次【隐藏时】执行(如：返回)
		onHide() {},
		// 函数
		methods: {
			// 页面数据初始化函数
			init(options) {
				this.title = options.title
				let str = '<p style=\"text-align: center;\">暂无相关信息...</p>'
				vk.callFunction({
					url: 'client/quest-bank/kh/vip/getMyCourseInfo',
					title: '请求中...',
					data: { id: options.cid },
					success: function(res) {
						switch (that.title) {
							case '核心知识点':
								that.richText = res.data.center_info || str
								break
							case '考前分析':
								that.richText = res.data.before_exam || str
								break
						}
					}
				});
			},
			pageBack() {
				uni.navigateBack({
					delta: 1
				})
			}
		},
	}
</script>

<style lang="scss" scoped>
	.page_bg {
		width: 100%;
		height: 100vh;
		overflow-y: auto;

		.status_bar,
		.top_view {
			background-color: #FFAC05;
		}

		.top_nav {
			padding-bottom: 24rpx;
			color: rgb(51, 51, 51);
			font-size: 34rpx;
			line-height: 41rpx;
			white-space: nowrap;
			background: linear-gradient(179deg, #FDD303 0%, #FFAC05 100%);
			height: 90rpx;
			position: relative;

			.image_1 {
				left: 21rpx;
				top: 27rpx;
				width: 19rpx;
				height: 35rpx;
				position: absolute;
			}

			.cate {
				width: 100%;
				padding: 20rpx 0;
				color: rgb(51, 51, 51);
				font-size: 34rpx;
				font-weight: 500;
				line-height: 41rpx;
				white-space: nowrap;
				text-align: center;
			}
		}
	}

	.rich {
		box-sizing: border-box;
		padding: 20rpx;
		height: calc(100% - 90rpx);
	}
</style>
